/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.balisunrise.swing.components.managers;

import java.util.Properties;
import javax.swing.JTextField;
import org.balisunrise.common.BindingGroup;
import org.balisunrise.components.ComponentManager;
import org.balisunrise.swing.components.util.BaliComponentFocusListener;

/**
 *
 * @author Glauco
 */
public abstract class AbstractJTextFieldComponentManager<T>
        implements ComponentManager<T, JTextField>{

    public Class<JTextField> getComponentType() {
        return JTextField.class;
    }

    public JTextField buildComponent(String componentName, Properties p) {

        int length = 60;

        if(p!= null)
            try{
                Object o = p.get("length");
                length = (Integer) o;
            } catch(Exception e){}

        JTextField aux = new JTextField(length);

        aux.addFocusListener(new BaliComponentFocusListener());

        aux.setName(componentName);
        aux.getAccessibleContext().setAccessibleName(componentName);

        return aux;
        
    }

    public void clearComponentValue(JTextField component) {
        if (null == component)
            return;
        if (component instanceof JTextField){
            component.setText("");
        }
    }

    public Object readValue(JTextField component) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void insertConvertedValue(Object propertyValue,
            JTextField component) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void createBinding(BindingGroup bindingGroup, Object source,
            String property, JTextField component) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

}
